package com.asd.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.asd.service.UserService;
import com.asd.vo.User;

@Controller
public class UserController {
	@Autowired
	private UserService userService;
	@RequestMapping("/login")
	public String selectUser(User user,Model model){
		System.out.println(user);
		System.out.println("进入登录方法");
		user=userService.selectUser(user);
		if(user!=null){
			model.addAttribute("user", user);
			System.out.println(user);
			return "/ok.jsp";
		}
		return null;
	}
	@RequestMapping("/update")
	public String updateUser(User user,Model model){
		System.out.println(user);
		System.out.println("进入更新方法");
		int i =userService.updateUser(user);
		System.out.println(i);
		return null;
	}
	@RequestMapping("/delete")
	public String deleteUser(User user,Model model){
		System.out.println(user);
		System.out.println("进入删除方法");
		int i =userService.deleteUser(user);
		System.out.println(i);
		return null;
	}
	@RequestMapping("/insert")
	public String insertUser(User user,Model model){
		System.out.println(user);
		System.out.println("进入添加方法");
		int i =userService.insertUser(user);
		System.out.println(i);
		return null;
	}
}
